﻿@model IEnumerable<LX.Models.Task>

@{
    ViewBag.Title = "Index";
}

<h2>Index</h2>
<form method="get" class="form-inline text-center" style="margin:10px">
    用户名：@Html.DropDownList("uid", null, new { @class = "form-control" })
    内容：<input type="text" name="Content" class="form-control" placeholder="请输入内容关键字" />
    <input type="submit" value="查询" class="btn btn-primary" />
    @Html.ActionLink("添加", "tianjia", null, new { @class = "btn btn-primary" })
</form>
<p>
    @Html.ActionLink("添加", "tianjia")
</p>
<table class="table">
    <tr>
        <th>
            @Html.DisplayNameFor(model => model.TaskPriority)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.Content)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.AddTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.TaskState)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.FinishedTime)
        </th>
        <th>
            @Html.DisplayNameFor(model => model.userinfo.name)
       
        </th>
        <th></th>
    </tr>

    @foreach (var item in Model)
    {
        <tr>
            <td>
                @if (item.TaskPriority == 1)
                {
                    @:一级紧急
                }
                else if (item.TaskPriority == 2)
                {
                    @:二级紧急
                }
                else
                {
                    @:三级紧急
                }
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.Content)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.AddTime)
            </td>
            <td>
                @(item.TaskState==1?"否":"是")
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.FinishedTime)
            </td>
            <td>
                @Html.DisplayFor(modelItem => item.userinfo.name)
            </td>
            <td>
                <a href="@Url.Action("xiugai","Default",new {te=item.TaskID })">修改</a>
                <a href="@Url.Action("xiangqing","Default",new {te=item.TaskID })">详情</a>
                <a href="#" data-del="@item.TaskID">删除</a>
            </td>
        </tr>
    }

</table>
@section scripts{
    <script type="text/javascript">
        $(function(){
            $('a[data-del]').click(function () {
                var $this = $(this);
                var id = $this.attr("data-del");
                if (!confirm("are you sure?删除第" + id + "行")) return;
                $.post('@Url.Content("~/Default/shanchu")', { id, id }, function (res) {
                    if (res == true) {

                        $this.closest("tr").remove();
                        alert("删除成功");
                    }
                })
            })
        })
    </script>
}
